#include "timer.h"

CTimer::CTimer() {

	m_Active = false;
	m_Duration = 0.0f;
	m_Time = 0.0f;
}

void CTimer::Set(const float duration) {
	
	if(duration < 0.0f)
		m_Duration = 0.0f;
	else
		m_Duration = duration;
}

void CTimer::Start() {
	m_Active = true;
}

void CTimer::Pause() {
	m_Active = false;
}

void CTimer::Reset() {
	m_Active = false;
	m_Time = 0.0f;
}

void CTimer::Update(const float dt) {
	if(m_Active) {
		m_Time += dt;
		m_Active = m_Time < m_Duration;
	}
}

bool CTimer::IsComplete() {
	return m_Time > m_Duration;
}

bool CTimer::IsActive() {
	return m_Active;
}